<template>
  <view class="dosage">
    <none-data v-if="payList.length === 0" />
    <recordsCard
      v-for="(item, index) in payList"
      :key="index"
      :type="type"
      :identifier="item.accountNumber"
      :balance="item.totalDosage"
      :time="item.weekInterval"
    />
    <view class="tail" v-if="payList.length !== 0">
      {{ tailText }}
    </view>
  </view>
</template>

<script setup>
import recordsCard from "@/package_property/pages/components/records-card/x.vue";
import { getWaterElectricityLogDayApi } from "@/package_property/pages/api/life-services.js";
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
const type = ref("");
const room = ref("");
const pageData = ref({
  page: 1,
  size: 10,
});
const payList = ref([]);
const tailText = ref("");
async function getWaterElectricityLogDay() {
  let options = {
    feeDeduction: type.value == "水表" ? "1" : "2",
    accountNumber: room.value,
    page: pageData.value.page,
    size: pageData.value.size,
  };
  const res = await getWaterElectricityLogDayApi(options);
  const { code, data } = res || {};
  if (code == 200) {
    console.log(data);
    payList.value = data.records;
    payList.value = data.records;
    if (payList.value.length !== data.total) {
      tailText.value = "下滑加载更多";
    } else {
      tailText.value = "没有更多内容";
    }
  }
}
onLoad((option) => {
  console.log(option);
  type.value = option.type;
  room.value = option.room;
  getWaterElectricityLogDay();
});
</script>

<style lang="less" scoped>
</style>